import request from '@/utils/request'

const sysPermissionApi = {
  Index: '/sys-permission/index',
  Save: '/sys-permission/save',
  Del: '/sys-permission/destroy',
  SetOrder: '/sys-permission/set-order'
}

/**
 * 加载列表数据
 * @returns {requestPromise}
 */
export function loadList (searcmParams = {}) {
    return request({
        url: sysPermissionApi.Index,
        method: 'get',
        params: searcmParams
    })
}

/**
 * 保存数据
 * @param postData
 * @returns {requestPromise}
 */
export function saveData (postData) {
    return request({
        url: sysPermissionApi.Save,
        method: 'post',
        data: postData
    })
}

/**
 * 删除数据
 * @param permIds
 * @returns {*}
 */
export function delData (permIds) {
    return request({
        url: sysPermissionApi.Del,
        method: 'post',
        data: { perm_ids: permIds }
    })
}

/**
 * 设置排序
 * @param draggingNode
 * @param dropNode
 * @param dropType
 * @returns {requestPromise}
 */
export function setOrder (draggingNode, dropNode, dropType) {
    return request({
        url: sysPermissionApi.SetOrder,
        method: 'post',
        data: { draggingNode: draggingNode, dropNode: dropNode, dropType: dropType }
    })
}
